<?php
Yii::app()->clientScript->registerScriptFile($this->adminPath . '/timepicker/js/jquery-1.7.1.min.js',CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/timepicker/js/jquery-ui-1.8.17.custom.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/timepicker/js/jquery-ui-timepicker-addon.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/timepicker/js/jquery-ui-timepicker-zh-CN.js",CClientScript::POS_HEAD);


Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.tipsy.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.wysiwyg.js",CClientScript::POS_HEAD);


Yii::app()->clientScript->registerScriptFile($this->adminPath."/timepicker/js/jquery-ui-timepicker-addon.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/timepicker/js/jquery-ui-timepicker-zh-CN.js",CClientScript::POS_HEAD);



Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/jquery.artDialog.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/plugins/iframeTools.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.validationEngine.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.validationEngine-zh_CN.js",CClientScript::POS_HEAD);


?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/art-dialog/skins/blue.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/validationEngine.jquery.css" />
<style type="text/css">
    .st-labeltext {
        color: #3C5868;
        display: block;
        float: left;
        font-size: 12px;
        line-height: 20px;
        padding-right: 10px;
        padding-top: 3px;
        width: 60px;
    }
</style>
<div style="z-index: -1;" class="albox succesbox">
    <span id="is_type" style="color: red;">基本信息</span>
</div>
<form id="form"  method="post" >
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">名称:</span>
    <input type="text" value="<?php echo $info->title ?>"  name="OpenPoint[title]" style="width:300px;margin-bottom: 10px;float: left" id="title" class="st-success-input validate[required,maxSize[80]]"  data-errormessage-range-overflow="名称不得大于80个字" data-errormessage-value-missing="名称不得为空" >
    <div class="clear" style="z-index: 570;"></div>
</div>
    <div class="st-form-line" style="z-index: 580;">
        <span class="st-labeltext">权重:</span>
        <input type="text" value="<?php echo $info->point ?>"  name="OpenPoint[point]" style="width:300px;margin-bottom: 10px;float: left" id="title" class="st-success-input validate[required,maxSize[80]]"  data-errormessage-range-overflow="权重不得大于80个字" data-errormessage-value-missing="权重不得为空" >
        <div class="clear" style="z-index: 570;"></div>
    </div>

<div class="st-form-line button-box" style="z-index: 460;">
    <input type="submit" class="st-button" value="保存" id="submit" name="button">
</div>
</form>

<script type="text/javascript">
    $(function() {
        $(function () {
            $("#begin-time").datetimepicker({
                monthNames : ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                monthNamesShort : ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                showSecond: true,
                changeMonth : true,
                changeYear : true,
                timeFormat: 'hh:mm:ss',
                stepHour: 1,
                stepMinute: 10,
                stepSecond: 10,
                minDate : 0,
                defaultDate: "+1w",
                onClose: function( dateText) {
                    $("#end-time").datetimepicker('option', 'minDate',dateText);
                }
            });
            $('#end-time').datetimepicker({
                monthNames : ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                monthNamesShort : ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                showSecond: true,
                changeMonth : true,
                changeYear : true,
                timeFormat: 'hh:mm:ss',
                stepHour: 1,
                stepMinute: 10,
                stepSecond: 10,
                minDate : 0,
                defaultDate: "+1w",
                onClose: function( dateText ) {
                    $("#start-time").datetimepicker('option', 'maxDate',dateText);
                }
            });
        });



    });

    $('#traffic_info').wysiwyg({
        controls: {
            bold : {visible : true},
            italic        : { visible : true },
            strikeThrough : { visible : true },
            underline     : { visible : true },
            separator00 : { visible : true },
            justifyLeft   : { visible : true },
            justifyCenter : { visible : true },
            justifyRight  : { visible : true },
            justifyFull   : { visible : true },
            separator01 : { visible : true },
            indent  : { visible : true },
            outdent : { visible : true },
            separator02 : { visible : true },
            subscript   : { visible : true },
            superscript : { visible : true },
            separator03 : { visible : true },
            undo : { visible : true },
            redo : { visible : true },
            separator04 : { visible : true },
            insertOrderedList    : { visible : true },
            insertUnorderedList  : { visible : true },
            insertHorizontalRule : { visible : true },
            separator05 : { separator : true },
            createLink:{
                visible : false,
                tooltip : '选择文字添加超链接'
            }

        }
    });



    //缩略图上传
    function uploadifyAction(Warp,Name) {
        art.dialog.data('Warp',Warp);
        art.dialog.data('Name',Name);
        art.dialog.open(
            '<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/file",array('t'=>'doc-xlsx')); ?>',
            {
                title:'附件上传',
                lock: false,
                width: 600,
                height: 300,
                ok: function () {
                    var fileListWarp = art.dialog.data('fileListWarp');

                    $("#"+Warp).html('<input type="text" value="'+fileListWarp+'"  name="Open[jiaoan]" style="width:300px;margin-bottom: 10px;float: left"  class="st-success-input "  >');
                    this.close();
                    return false;
                },
                cancelVal: '取消',
                cancel: true
            }

        );
    }
    function uploadifyRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $.post(
                "<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/remove"); ?>",
                {imageId:fileId},
                function(res){
                    $("#"+attrName+fileId).remove();
                },
                'json'
            );
        }
    }

    function relatedRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $("#"+attrName+fileId).remove();
        }
    }





    $(function(){
        $("#gid").change(function() {
            loadClass($("#gid").val());
        });
        function loadClass(gid) {
            $.ajax({
                url: '<?php echo Yii::app()->createAbsoluteUrl("admin/people/loadClass"); ?>'+ 'gid/' +gid,
                type: 'POST',
                dataType: 'html',
                success: function(msg) {
                    $("#cid").html(msg);
                }
            });
        }
        $("#map").click(function(){
            var city_name = '<?php echo Yii::app()->admin->getState('city_title'); ?>';
            art.dialog.open(
                '<?php echo Yii::app()->createAbsoluteUrl("admin/public/getMap"); ?>',
                {
                    title:'地图标注',
                    lock: true,
                    width: 700,
                    height: 500,
                    close: function(){
                        var maps = art.dialog.data('maps');
                        $("#coordinate").val(maps);
                    }
                });
            art.dialog.data('city_address', city_name);
            art.dialog.data('coordinate', $("#coordinate").val());
        });
        $("#related").click(function(){
            art.dialog.open(
                '<?php echo Yii::app()->createAbsoluteUrl("admin/public/getRelated",array('type'=>'destination','city'=>$city_id)); ?>',
                {
                    title:'周边',
                    lock: true,
                    width: 700,
                    height: 580,
                    close: function(){
                        var aid = art.dialog.data('aid');
                        var atitle = art.dialog.data('atitle');
                        if(aid && atitle){
                            var str = '';
                            str += '<li id="related_'+aid+'" style="padding:5px 5px;cursor: pointer;border-bottom: 1px solid #ccc;display: table;"><label>'+atitle+'</label><span style="margin-left: 170px;"><a href="javascript:relatedRemove('+aid+',\'related_\')">删除</a></span><input name="relation[]" value="'+aid+'" type="hidden" /></li>';
                            $("#relatedWarp").append(str);
                        }
                    }
                });
        });




    });



    $(function(){
        $("#form").validationEngine({
            ajaxFormValidation: true,
            ajaxFormValidationURL: '<?php echo Yii::app()->createAbsoluteUrl('admin/observation/childPointUpdate',array('id'=>$info->id)); ?>',
            ajaxFormValidationMethod: "post",
            //validateNonVisibleFields:true,//验证隐藏字段
            onBeforeAjaxFormValidation: function (form, options) {
                luck = false;
                art.dialog.Talert('数据交互中ing', 5);
            },
            onAjaxFormComplete: function (status, form, json, options) {
                if (json['status'] == 1) {
                    art.dialog.Talert(json['message']);
                    var win = art.dialog.open.origin;
                    win.location.reload();
                } else {
                    luck = true;
                    art.dialog.Talert(json['message']);
                }
            }

        });
    });
</script>
